refactor: Function to get execution status stats#95
refactor: Function to get execution status stats#95yuechao-qin wants to merge 1 commit intomasterfrom
Conversation
1229fcb to
f086771
Compare
2dab4d8 to
b6873b2
Compare
f086771 to
e2e05ef
Compare
b6873b2 to
b18d382
Compare
b18d382 to
546f75f
Compare
e2e05ef to
e382bc8
Compare
e382bc8 to
5ae141c
Compare
morgan-wowk
left a comment
There was a problem hiding this comment.
I can see that it is functionally the same from a production code point of view. Just left some comments on the tests.
Thanks for doing this!
| from cloud_pipelines_backend import database_ops | ||
| from cloud_pipelines_backend.api_server_sql import ( | ||
| ExecutionStatusSummary, | ||
| PipelineRunsApiService_Sql, |
There was a problem hiding this comment.
:nit
If we are treating test code with the same standard as production code then I'll just mention:
Alexey has asked me to import modules (api_server_sql) rather than directly importing classes or function.
So you would use api_server_sql.ExecutionStatusSummary rather than ExecutionStatusSummary directly in this file. Same with other imports.
| session.flush() | ||
|
|
||
|
|
||
| def _create_pipeline_run(session, root_execution, created_by=None, annotations=None): |
There was a problem hiding this comment.
Let's use Python type annotations everywhere in function signatures.
| def _create_pipeline_run(session, root_execution, created_by=None, annotations=None): | ||
| """Helper to create a PipelineRun linked to a root execution node.""" | ||
| run = bts.PipelineRun(root_execution=root_execution) | ||
| if created_by: |
There was a problem hiding this comment.
This conditionals are not needed. You can just construct the PipelineRun object.

TL;DR
Refactored execution status stats calculation and added comprehensive tests for the pipeline runs API service.
What changed?
_get_execution_status_statsPipelineRunsApiService_SqlclassHow to test?
Run the new test cases in
tests/test_api_server_sql.py:Why make this change?
Created this function to be used in upstream PRs for Pipeline Run API (list and get)